package cn.okcode.api.framework.js;

import cn.okcode.api.framework.annotation.CPAction;
import cn.okcode.api.framework.annotation.CPAutowired;
import cn.okcode.api.framework.annotation.CPParam;
import cn.okcode.api.framework.result.MineType;
import cn.okcode.api.framework.result.ResultHandlerEnum;
import cn.okcode.api.framework.annotation.CPController;

import java.util.List;

/**
 * js服务类，用于生成controller的js调用方法
 *
 * @author pyk13
 */
@CPController
public class JsController {

    @CPAutowired
    private JsService js;

    @CPAction(resultHandler = ResultHandlerEnum.RAW, mineType = MineType.JS)
    public String makeInvoker() {
        return js.build();
    }

    @CPAction()
    public Object executeIL(@CPParam("opCodes") String[] opCodes) {
        ILInterpreter interpreter = new ILInterpreter(opCodes);
        return interpreter.execute();
    }

    @CPAction()
    public List<ClassInfoBean> getClassInfo(@CPParam("classNames") String[] classNames) {
        ClassInfoHelper interpreter = new ClassInfoHelper();
        return interpreter.getClassInfo(classNames);
    }
}
